package cc.avatar.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * Accounting Entries help keep a record of changes to an account.
 * <ul>每一个Party仅对应唯一的一种帐务条目，如下
 * <li>运输班组 每完成一个运输单，会产生一笔运输费条目。
 *     如果发生 退板，也会产生一笔 对冲的运费。</li>
 * <li>生产班组 将新产品入库，每个入库单产生一条帐目。</li>    
 * <li>销售人员 在销售单收款完成后，会产生销售佣金条目。</li>
 * </ul>
 */

@Entity
@Table(name="t_accounting_entry") 
public class AccountingEntry {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	private double amount;
	//发生时间
	private Date date;
	
	private String att1;
	private String att2;
	private String att3;
	private String att4;

	//帐务相关人
	@ManyToOne(cascade = {CascadeType.ALL})
	private Party party;
	//for hibernate
	public AccountingEntry(){}
	public AccountingEntry(Party owner, double amount, Date date,
			String att1, String att2, String att3, String att4){
		this.party = owner;
		this.amount = amount;
		this.date = date;
        this.att1 = att1;
        this.att2 = att2;
        this.att3 = att3;
        this.att4 = att4;
    }
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public double getAmount() {
		return amount;
	}
	public Party getParty() {
		return party;
	}

	public Date getDate() {
		return date;
	}
	public String getAtt1() {
		return att1;
	}
	public void setAtt1(String att1) {
		this.att1 = att1;
	}
	public String getAtt2() {
		return att2;
	}
	public void setAtt2(String att2) {
		this.att2 = att2;
	}
	public String getAtt3() {
		return att3;
	}
	public void setAtt3(String att3) {
		this.att3 = att3;
	}
	public String getAtt4() {
		return att4;
	}
	public void setAtt4(String att4) {
		this.att4 = att4;
	}
	
}
